package com.bw.module_staff.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bw.module_staff.databinding.ItemStaffLayoutBinding
import com.bw.module_staff.entity.StaffEntity
/**
 * 工单-智慧园区-人员管理
 */

class StaffAdapter(val data:MutableList<StaffEntity>): RecyclerView.Adapter<StaffAdapter.StaffItemViewHolder>() {

    inner class StaffItemViewHolder(val itemDataBindingUtil: ItemStaffLayoutBinding) : RecyclerView.ViewHolder(itemDataBindingUtil.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): StaffItemViewHolder {
        val itemDataBindingUtil = ItemStaffLayoutBinding.inflate(LayoutInflater.from(parent.context),parent,false)
        return StaffItemViewHolder(itemDataBindingUtil)
    }

    override fun getItemCount(): Int {
        return data.size
    }

    override fun onBindViewHolder(holder: StaffItemViewHolder, position: Int) {
        val entity = data[position]
        holder.itemDataBindingUtil.name.text = entity.name
        if (entity.departmentId==16){
            holder.itemDataBindingUtil.department.text = "研发部"
            holder.itemDataBindingUtil.desc.text = "研发部门经理"
        }else  if (entity.departmentId==17){
            holder.itemDataBindingUtil.department.text = "技术部"
            holder.itemDataBindingUtil.desc.text = "高级前端工程师"
        }else  if (entity.departmentId==18){
            holder.itemDataBindingUtil.department.text = "市场部"
            holder.itemDataBindingUtil.desc.text = "市场总监"
        }
    }
}
